/**
 * 从地址栏传值的代码
 * @param param
 * @returns
 */
function getParameter(param){
	var query = window.location.search;
	var iLen = param.length;
	var iStart = query.indexOf(param);
	if (iStart == -1)
		return "";
	iStart += iLen + 1;
	var iEnd = query.indexOf("&", iStart);
	if (iEnd == -1)
		return query.substring(iStart);
	return query.substring(iStart, iEnd);
}

layui.use('table', function(){
  var table = layui.table;
   
   
 
   
  setTimeout(() => {
	  var $ = layui.$, active = {
			    reload: function(){
			      var muId=$("#muId");
			      //执行重载    查询
			      table.reload('purchaseDetail', {
			        page: {
			          curr: 1 //重新从第 1 页开始
			        }
			        ,where: {
			        	prodId: getParameter("prodId"),
			        	muId: muId.val()
			        }
			      });
			      
			      table.reload('manufacture', {
				        page: {
				          curr: 1 //重新从第 1 页开始
				        }
				        ,where: {
				        	prodId: getParameter("prodId"),
				        	muId: muId.val()
				        }
				      });
			    }
			  };
	  active['reload'] ? active['reload'].call(this) : '';
	  
	  $('.demoTable #search').on('click', function(){
	    var type = $(this).data('type');
	    active[type] ? active[type].call(this) : '';
	  });
  }, 200);
  //表单重载
  
  
 
});
 
layui.use(['form', 'table'], function(){
	  var form = layui.form
	  var table = layui.table
	  var layer = layui.layer
	  
	var url="../../listenMusical/selectAll.action";
	var data=null
	$.post(url,data,function(mes){
		 $.each(mes.data,function(i,item){
				 $("#muId").append("<option value="+item.muId+">"+item.muName+"</option>")
  				  load();
		  })
	},"json");
	
	

	  
});
function load(){
	var form = layui.form;
	form.render();
}
